package com.comment.util.message;

import java.math.BigDecimal;
import java.util.List;


public class ListUtil {

    public static Double getDoubleOrDefault(List<Double> probability, Integer skillStar, Double defaultValue) {
        // 检查 probability 是否为 null
        if (probability == null) {
            return defaultValue;
        }

        // 检查 skillStar 是否在有效范围内
        int size = probability.size();
        if (skillStar < 0 || skillStar >= size) {
            return defaultValue;
        }
        Object v = probability.get(skillStar);
        String s = v.toString();

        // 获取值
        return new BigDecimal(s).doubleValue();
    }
}
